#ifndef WAVE_H
#define WAVE_H

#include <QObject>
#include <QStringList>
#include <QFile>

typedef struct wave_header_nt {
    uint32_t	RIFFChunkID;	// "RIFF"
    uint32_t	RIFFChunkSize;
    uint32_t	WAVEID;			// "WAVE"

    uint32_t	fmtXChunkID;	// "FMT"
    uint32_t	fmtXChunkSize;
    uint16_t	FormatTag;
    uint16_t	NumChannels;
    uint32_t	SampleRate;
    uint32_t	ByteRate;
    uint16_t	BlockAlign;
    uint16_t	BitsPerSample;

    uint32_t 	factChunkID;	//"FACT"
    uint32_t 	factChunkSize;

    uint32_t	dataChunkID;	// "DATA"
    uint32_t	dataChunkSize;

    uint32_t    head_size;
    uint32_t    audio_size;
} WAVE_HEAD_S;

class WaveInfo : public QObject
{
    Q_OBJECT
public:
    WaveInfo();

    static WaveInfo* instance();

signals:
    void signalWaveInfo(const QString&);

public:
    bool check_waveinfo(const QString&, bool showall = false);
    void merge_wave(const QString&, const QStringList&);

private:
    bool check_wavehead(WAVE_HEAD_S &, char*, uint32_t);
    void merge_wave_item(const QString&);

    char _wav_head[512];
    bool _merge_exec = false;
    QFile *_mfile = nullptr;
    uint32_t _head_size = 0;
    uint32_t _audio_size = 0;
};

#endif // WAVE_H
